package com.cszy.yydqbfq.ext

import androidx.annotation.IdRes
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import qrrspeeelild.rqrc0ode.andro0ild.R


/**
 * 添加Fragment
 */
fun FragmentActivity.replaceFragment(@IdRes viewId: Int, fragment: Fragment) {
    supportFragmentManager
        .beginTransaction()
        .setCustomAnimations(
            R.anim.slide_in_right,
            R.anim.slide_out_left,
            R.anim.slide_in_left,
            R.anim.slide_out_right
        )
        .replace(viewId, fragment)
        .addToBackStack(null)
        .commit()
}

fun Fragment.replaceFragment(@IdRes viewId: Int, fragment: Fragment) {
    childFragmentManager
        .beginTransaction()
        .setCustomAnimations(
            R.anim.slide_in_right,
            R.anim.slide_out_left,
            R.anim.slide_in_left,
            R.anim.slide_out_right
        )
        .replace(viewId, fragment)
        .addToBackStack(null)
        .commit()
}


